Basic Computer Skills .htm

About us  Contact  post comment  Teb Computer Academy  

TEB   Computer  Kids  Academy

Data Science

Data Science - Slope and Intercept:



Slope and Intercept
let us explain how we found the slope and intercept of our function:

f(x) = 2x + 80

The image below points to the Slope - which indicates
how steep the line is,
and the Intercept - which is the value of y,
when x = 0 (the point where the diagonal line
crosses the vertical axis).
The red line is the continuation of the blue line from previous page.



To Find The Slope:
Slope is defined as how much calorie burnage increases,
if average pulse increases by one.
It tells us how "steep" the diagonal line is.

You can find the Slope by using the
proportional difference of two points from the graph.

meaning that - If the average pulse is 80, the calorie burnage is 240
If the average pulse is 90, the calorie burnage is 260

We notice that if average pulse increases with 10,
the calorie burnage increases by 20.
Slope = 20/10 = 2
The slope is 2.

Slope is Mathematically defined as:

Slope = f(x2) - f(x1) / x2-x1
f(x2) = Second observation of Calorie_Burnage = 260
f(x1) = First observation of Calorie_Burnage = 240
x2 = Second observation of Average_Pulse = 90
x1 = First observation of Average_Pulse = 80
Slope = (260-240) / (90 - 80) = 2

let us use Python to Find the Slope

you can calculate the slope with the following code:

Example:

def slope(x1, y1, x2, y2):
s = (y2-y1)/(x2-x1)
return s
print (slope(80,240,90,260))


Output:


let us find The Intercept

The intercept is the value of y, when x = 0.
we see that if average pulse (x) is zero,
then the calorie burnage (y) is 80.
So, the intercept is 80.

We can now find the Slope and Intercept Using Python

Example:
import pandas as pd
import numpy as np
health_data = pd.read_csv("data.csv", header=0, sep=",")
x = health_data["Average_Pulse"]
y = health_data["Calorie_Burnage"]
slope_intercept = np.polyfit(x,y,1)
print(slope_intercept)




now we have calculated the slope (2) and the intercept (80).
We can write the mathematical function as follow:

You can Predict Calorie_Burnage by using a mathematical expression:
f(x) = 2x + 80

Note that the intercept is a constant.
A constant is a number that does not change.
We can now substitute the input x with 135:
f(135) = 2 * 135 + 80 = 350
If average pulse is 135, the calorie burnage is 350.

Use Python to define the Mathematical Function.

Example
def my_function(x):
return 2*x + 80
print (my_function(135))

Output:


Professional courses:

participant -Kids, Youths and Adults alike
learn and aquire these professional Courses

Professional Courses:


  • Informatiker

  • Website programming

  • IT Consultant

  • IT Security

  • Java Programming
  • Software Developer

  • IT Admin.

  • IT FORENSIC


  • Python Programming
  • programming with C++
  • Data Science



  • Are you parents, teachers or affiliate schools, pls. click here.








    click here to view 'KITAS' arround you